public class TestString02 {
    public static void main(String[] args) {
        String s = "";
        String s1 = "How are you?";
        System.out.println(s1.startsWith("How"));   //是否以How开头：true
        System.out.println(s1.endsWith("you"));     //是否以you结尾：false
        s = s1.substring(4);    //提取子字符串，从下标为4开始到字符串结尾：are you?
        System.out.println(s);
        s = s1.substring(4,7);      //提取子字符串：下标[4,7) 不包括7：are
        System.out.println(s);
        s = s1.toLowerCase();       //转小写：how are you?
        System.out.println(s);
        s = s1.toUpperCase();       //转大写：HOW ARE YOU?
        System.out.println(s);

        String s2 = "  How old are you!  ";
        s = s2.trim();      //去除字符串首尾的空格。注意：中间的空格不能去除
        System.out.println(s2);
        System.out.println(s);
    }
}
